package cn.liujianbo.example.validate.controller;

import cn.liujianbo.example.validate.listener.event.MyEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 刘建波
 * @date 2021-09-08 17:14
 */
@RestController
@RequestMapping("/test")
public class TestMyEventListenerController {
    @Autowired
    private ApplicationEventPublisher publisher;

    @GetMapping("/{resource}")
    public void test(@PathVariable("resource") String source) {
        System.out.println("source = " + source);
        publisher.publishEvent(new MyEvent(source));
    }

}
